package com.loongtech.bi.support;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
@Scope("session")
public class Session implements java.io.Serializable
{
	private static final long	serialVersionUID	= -2386014290706530058L;
	private String				userName;
	private int					userId;
	private boolean				admin;

	@Autowired
	public void init()
	{
		Log.bi.debug("Session创建");
	}

	public boolean isLogin()
	{
		return !StringUtils.isBlank(userName);
	}
	
	public int getUserId()
	{
		return userId;
	}

	public void setUserId(int userId)
	{
		this.userId = userId;
	}
	
	public String getUserName()
	{
		return this.userName;
	}
	
	public void setUserName(String userName)
	{
		this.userName = userName;
	}

	public boolean isAdmin()
	{
		return admin;
	}

	public void setAdmin(boolean admin)
	{
		this.admin = admin;
	}

	@Override
	public String toString()
	{
		return "Session [userId=" + userId + ", userName=" + userName + ", admin=" + admin + "]";
	}
}
